<template>
  <div class="top">
    <div class="content">
      <div class="left" @click="goHome">
        <img src="../../assets/images/logo.png" alt="" />
        <p>尚医通 预约挂号统一平台</p>
      </div>
      <div class="right">
        <p class="help">帮助中心</p>
        <p class="login" @click="login" v-if="!useStore.userInfo.name">登录</p>
        <el-dropdown v-else>
          <span class="el-dropdown-link">
            {{ useStore.userInfo.name }}
            <el-icon class="el-icon--right">
              <arrow-down />
            </el-icon>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>实名认证</el-dropdown-item>
              <el-dropdown-item>挂号订单</el-dropdown-item>
              <el-dropdown-item>就诊人管理</el-dropdown-item>
              <el-dropdown-item @click="ligout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts" name="HospitalTop">
import { ArrowDown } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import useUserStore from "@/store/modules/user";
let useStore = useUserStore();
let $router = useRouter();
// 跳转回home
const goHome = () => {
  $router.push({ path: "/home" });
};
let login = () => {
  useStore.visiable = true;
};
// 退出登录按钮回调
let ligout=()=>{
    // pinia仓库清除用户信息
    useStore.logout()
    // 编程导航路由跳转首页
    $router.push({path:'/home'})
}
</script>
<style lang="scss" scoped>
.top {
  // 固定在上面
  position: fixed;
  z-index: 999;
  width: 100%;
  height: 70px;
  background-color: #fff;
  display: flex;
  justify-content: center;
  .content {
    cursor: pointer;
    width: 1200px;
    height: 70px;
    display: flex;
    justify-content: space-between;

    .left {
      display: flex;
      justify-content: center;
      align-items: center;
      img {
        width: 50px;
        height: 50px;
        margin-right: 10px;
      }
      p {
        font-size: 20px;
        color: #55a6fe;
      }
    }

    .right {
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      .help {
        margin-right: 10px;
      }
    }
  }
}
</style>
